package com.mdx.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mdx.bean.GalleryBean;
import com.mdx.bean.RodentBean;
import com.mdx.dao.GalleryDao;
import com.mdx.service.IGalleryService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDate;

@Service
@Transactional
public class GalleryServiceImpl extends ServiceImpl<GalleryDao, GalleryBean> implements IGalleryService {
    @Override
    public IPage<GalleryBean> showByItem(int pageNO, int pageSize, String className, LocalDate start, LocalDate end) {
        IPage<GalleryBean> page = new Page<>(pageNO,pageSize);
        QueryWrapper wrapper = new QueryWrapper();
        if (className != null && !className.equals("")){
            wrapper.like("f_className",className);
        }
        if (start != null ) {
            wrapper.ge("f_outTime", start);
        }
        if (end != null) {
            wrapper.le("f_outTime", end);
        }
        IPage<GalleryBean> iPage = this.page(page,wrapper);
        return iPage;
    }

    @Override
    public GalleryBean findById(int galleryId) {
        return this.baseMapper.findById(galleryId);
    }
}
